﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;

namespace PearTunes.Client
{
    /// <summary>
    /// Interaction logic for LocalMusicListAndCoverFlow.xaml
    /// </summary>
    public partial class LocalMusicListAndCoverFlow : Page
    {
        public PlayList pls = new PlayList(true);
        public LocalMusicPage localPage; // = new LocalMusicPage();

        private PlayListManager playListManager;

        public LocalMusicListAndCoverFlow(ref PlayListManager playListManager)
        {
            InitializeComponent();
            this.playListManager = playListManager;
            localPage = new LocalMusicPage(ref playListManager);
            localPage.musicDataGrid.SelectionChanged += new SelectionChangedEventHandler(musicDataGrid_SelectionChanged);
            musicListFrame.Navigate(localPage);
            MusicLoad();
        }

        void musicDataGrid_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            flowControl.Index = (sender as DataGrid).SelectedIndex;
        }


        private void MusicLoad()
        {
            foreach (var a in pls)
            {
                flowControl.Add((a as LocalTrack).BitPicture);
            }
        }

        private void flowControl_IndexChanged(object sender, RoutedEventArgs e)
        {
            (musicListFrame.Content as LocalMusicPage).SelectIndexAt(flowControl.Index);
        }

    }
}
